package tw.com.hitevision.whiteboard.android.widgets;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.constraintlayout.widget.ConstraintLayout;
import tw.com.hitevision.whiteboard.android.R;

public class ExitAlertView extends ConstraintLayout {


    private View cancel,ok,cancel2,ok2,smallDialog,bigDialog;
    private Listener listener;

    public ExitAlertView(Context context) {
        super(context);
        init(context);
    }

    public ExitAlertView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public ExitAlertView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    public void setListener(Listener listener) {
        this.listener = listener;
    }

    private void init(Context context) {
        inflate(context,R.layout.menu_alert_exit,this);

        smallDialog = findViewById(R.id.dialog_small);
        bigDialog = findViewById(R.id.dialog_big);
        setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                listener.onCancelClicked();
            }
        });

        cancel = findViewById(R.id.negative);
        cancel.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                listener.onCancelClicked();
            }
        });

        cancel2 = findViewById(R.id.negative_2);
        cancel2.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                listener.onCancelClicked();
            }
        });

        ok = findViewById(R.id.positive);
        ok.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                listener.onExitClicked();
            }
        });

        ok2 = findViewById(R.id.positive_2);
        ok2.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                listener.onExitClicked();
            }
        });
    }

    public void setEmptyExitDialogMode(boolean b) {
        smallDialog.setVisibility(b?GONE:VISIBLE);
        bigDialog.setVisibility(b?VISIBLE:GONE);
    }


    public interface Listener {
        void onExitClicked();

        void onCancelClicked();
    }

}
